package it.giuseppetrisciuoglio.lyrics.utils;

import java.io.IOException;
import java.io.StringWriter;

import javax.annotation.Resource;
import javax.xml.transform.stream.StreamResult;

import org.springframework.oxm.Marshaller;
import org.springframework.stereotype.Component;

@Component
public class AdapterUtilities {
    
	@Resource(name="adapterMarshaller")
    private Marshaller marshaller;

    public String createXMLString(Object object) {
        StringWriter stringWriter = new StringWriter();
        StreamResult result = new StreamResult(stringWriter);
        try {
            marshaller.marshal(object, result);
        } catch (IOException e) {
            throw new RuntimeException(e.getMessage(), e);
        }
        return stringWriter.toString();
    }
}
